﻿using Castle.DynamicProxy;


namespace SBlogCore.Common.AutofacExtend.Aops
{
    /// <summary>
    /// 拦截器LogAOP 继承IInterceptor接口
    /// </summary>
    [SkipScan]
    public class CoreLogAop : IInterceptor
    {
        /// <summary>
        /// 实例化IInterceptor唯一方法 
        /// </summary>
        /// <param name="invocation"></param>
        /// <exception cref="NotImplementedException"></exception>
        public void Intercept(IInvocation invocation)
        {
            Console.WriteLine("你正在调用方法 \"{0}\"  参数是 {1}... ",
                   invocation.Method.Name,
                   string.Join(", ", invocation.Arguments.Select(a => (a ?? "").ToString()).ToArray()));

            invocation.Proceed();

            Console.WriteLine("方法执行完毕，返回结果：{0}", invocation.ReturnValue);
        }
    }
}
